package com.mall.implementation;

import java.util.ArrayList;

import com.mall.core.Customer;
import com.mall.core.Inventory;
import com.mall.core.Ledger;
import com.mall.core.ShopingCart;
import com.mall.core.StoreOwner;
import com.mall.util.StringWrapper;

public class StoreImpl  implements com.mall.core.Store{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private  ArrayList<Customer> customers = new ArrayList<Customer>();
	private  ArrayList<Customer> bannedcustomers = new ArrayList<Customer>();
	private Inventory inventory ;
	private StoreOwner storeowner;
	private int id;
	private StringWrapper name;
	@Override
	public ArrayList<Customer> getCurrentCustomers() {

		return this.customers;
	}

	@Override
	public void setCustomer(Customer customer) {
		this.customers.add(customer);
		
	}

	@Override
	public Inventory getIventory() {

		return inventory;
	}

	@Override
	public void setInventory(Inventory inventory) {
		this.inventory=inventory;
		
	}

	@Override
	public StoreOwner getStoreOwner() {

		return this.storeowner;
	}

	@Override
	public void setStoreOwner(StoreOwner storeowner) {
		this.storeowner = storeowner;
		
	}

	@Override
	public void DisplayStoreFront() {
		// TODO Auto-generated method stub
		//gui;
		
	}

	@Override
	public void DisplayBackEnd() {
		// TODO Auto-generated method stub
		//gui
	}

	@Override
	public void Checkout(ShopingCart shoppingcart) {
		RegisterImpl storeregister= new RegisterImpl();
		if(storeregister.isprintingReceipt()){}
		else{
			storeregister.processCheckout(shoppingcart);
		}
	}

	@Override
	public void setledger(Ledger ledger) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public Ledger getLedger() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void letInCustomer( Customer customer) {
		for(Customer customerr: bannedcustomers){
			if(customer.getId()==customerr.getId()){
				this.LetOutCustomer(customer);
				System.out.println("banned out of store");
			}
			else{
				customer.setInstore();
				customers.add(customer);
			
			}
		}
		

		
	}

	@Override
	public void LetOutCustomer(Customer customer) {
		for(Customer customerr : customers)
			if(customer.getId()==customerr.getId()){
				customers.remove(customer);
				customerr.setOutofstore();
			}
		
	}

	@Override
	public StringWrapper getName() {
		// TODO Auto-generated method stub
		return this.name;
	}

	@Override
	public void SetName(StringWrapper name) {
		this.name=name;
		
	}

	@Override
	public int getId() {
	
		return this.id;
	}

	@Override
	public void setId(int id) {
		this.id = id;
		
	}


}
